home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / IntArrayOption.java < prev    next >
Text File  |  1998-09-08  |  2KB  |  96 lines

  1. package com.symantec.itools.frameworks.application.commandline;
  2.  
  3.  
  4. /**
  5.  * @author Symantec Internet Tools Division
  6.  * @version 1.0
  7.  * @since VCafe 3.0
  8.  */
  9.  
  10. public abstract class IntArrayOption 
  11.     extends ArrayOption
  12. {
  13.     public IntArrayOption()
  14.     {
  15.     }
  16.  
  17.     public IntArrayOption(String[] flags)
  18.     {
  19.         super(flags);        
  20.     }
  21.  
  22.     public IntArrayOption(String[] flags, int count)
  23.     {
  24.         super(flags, count);
  25.     }
  26.  
  27.     /**
  28.      * @param args TODO
  29.      * @param startIndex TODO
  30.      * @exception com.symantec.itools.frameworks.application.commandline.MissingArgumentsException
  31.      * @since VCafe 3.0
  32.      */
  33.  
  34.     /*
  35.         args[ start_index ] will be the flag.
  36.         args[ start_index + 1 ] should be the first integer value
  37.     */
  38.     protected int[] getIntArray(String[] args, int startIndex)
  39.         throws MissingArgumentsException
  40.     {
  41.         int[] array;
  42.         
  43.         array = new int[count];
  44.         
  45.         try
  46.         {
  47.             for(int i = 0; i < count; i++)
  48.             {
  49.                 array[i] = Integer.parseInt(args[startIndex + i + 1]);
  50.             }
  51.         }
  52.         catch(ArrayIndexOutOfBoundsException ex)
  53.         {
  54.             throw new MissingArgumentsException(args[startIndex]);
  55.         }
  56.         
  57.         return (array);
  58.     }
  59.  
  60.     /**
  61.      * @param args TODO
  62.      * @param startIndex TODO
  63.      * @param count TODO
  64.      * @exception com.symantec.itools.frameworks.application.commandline.MissingArgumentsException
  65.      * @since VCafe 3.0
  66.      */
  67.  
  68.     /*
  69.         args[ start_index ] will be the flag.
  70.         args[ start_index + 1 ] should be the first integer value
  71.     */
  72.     protected int[] getIntArray(String[] args, int startIndex, int count)
  73.         throws MissingArgumentsException
  74.     {
  75.         int[] array;
  76.         
  77.         this.count = count;
  78.         array   = new int[count];
  79.  
  80.         try
  81.         {
  82.             for(int i = 0; i < count; i++)
  83.             {
  84.                 array[i] = Integer.parseInt(args[startIndex + i + 1]);
  85.             }
  86.         }
  87.         catch(ArrayIndexOutOfBoundsException ex)
  88.         {
  89.             throw new MissingArgumentsException(args[startIndex]);
  90.         }
  91.         
  92.         return (array);
  93.     }
  94. }
  95.  
  96.